<?php

namespace App\System\Base\Repositories;

use App\Module\Api\Controllers\Request\DeleteActionRequest;
use App\System\Base\Helpers\Traits\SinglePattern;
use App\System\Cis\Model\CisBankAccount;
use App\System\Cis\Model\CisUserAddress;
use App\System\Order\Model\OrderInfo;


class BaseDeleteRepository extends Repository
{
    use SinglePattern;

    public function delete(DeleteActionRequest $deleteActionRequest ,$user_id)
    {

        foreach ($deleteActionRequest->ids as $v)
        {
            if(!$v) continue;
            switch ($deleteActionRequest->action)
            {
                case 1:
                    //订单
                    OrderInfo::where('id',$v)->where('status',5)->where('user_id',$user_id)->delete();
                    break;
                case 2:
                    //银行卡
                    CisBankAccount::where('id',$v)->where('user_id',$user_id)->delete();
                    break;
                case 3:
                    //收货地址
                    CisUserAddress::where('id',$v)->where('user_id',$user_id)->delete();
                    break;
            }
        }
        return ['s'=>'0',"d"=>'操作成功'];
    }
}